package com.awenhui.demo.log;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author yuxf
 * @version 1.0
 * @date 2021/4/14 17:59
 */
@Component
@Slf4j
public class DefaultLogAop extends AbstractLogAop {

    @Override
    public void saveLog(LogDto logDto,LogOperation logOperation, JoinPoint joinPoint, HttpServletRequest request) {
       //如果有不能序列化的参数则会报错
        log.info("DefaultLogAop:{}",logDto);
    }

    /**
     * 重写获取用户信息
     * @return
     */
    @Override
    public String getUserName(HttpServletRequest request) {
        return this.getClass().getName()+"-UserName";
    }

    /**
     * 序列化请求参数
     * @param params
     * @return
     */
    @Override
    protected String serializeParams(Map<String, Object> params) {
        return super.serializeParams(params);
    }

    /**
     * 序列化响应结果
     * @param result
     * @return
     */
    @Override
    protected String serializeResult(Object result) {
        return super.serializeResult(result);
    }
}
